<template>
  <div>
    <van-address-list
      v-model="chosenAddressId"
      :list="addresslist"
      default-tag-text="默认"
      disabled-text="以下地址超出配送范围"
      @add="onAdd"
      @edit="onEdit"
      @select="everys"
    />
  </div>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
import Vue from "vue";
import { AddressList } from "vant";
import { Toast } from "vant";
Vue.use(AddressList);

export default {
  props: [],
  components: {},
  data() {
    return {
      users: {},
      chosenAddressId: "1",
    };
  },
  computed: {
    ...mapGetters({
      addresslist: "address/list",
    }),
  },
  methods: {
    ...mapActions({
      reqchangelist: "address/reqchangelist",
    }),
    onAdd() {
      Toast("新增地址");
      this.$router.push("/address");
    },
    onEdit(item, index) {
      // console.log(item);
      Toast("编辑地址:" + index);
      this.$router.push("/address?index=" + index + "&id=" + item.id);
    },
    everys(item) {
      this.$router.push("/order?id=" + item.id);
    },
  },
  mounted() {
    this.reqchangelist();
  },
};
</script>

<style scoped>
</style>